import request from '@/utils/request'
import { ResponsePermissionData, Menuparams } from './type'

enum API {
  GETPERMINMTION_URL = '/admin/acl/permission',
  ADDMENUPERMISSION_URL = '/admin/acl/permission/save',
  UPDATEMENUMISSION_URL = '/admin/acl/permission/update',
  DELETEPERMISSION_URL = '/admin/acl/permission/remove/',
}
//获取菜单信息
export const getPermission = () =>
  request.get<any, ResponsePermissionData>(API.GETPERMINMTION_URL)
//添加或修改菜单信息
export const AddOrUpdatePermission = (data: Menuparams) => {
  if (data.id) {
    return request.put<any, any>(API.UPDATEMENUMISSION_URL, data)
  } else {
    return request.post<any, any>(API.ADDMENUPERMISSION_URL, data)
  }
}
//删除菜单
export const DeleteMenu = (id: number) =>
  request.delete<any, any>(API.DELETEPERMISSION_URL + id)
